package com.nbsaas.boot.solution.rest.convert;

import com.nbsaas.boot.solution.data.entity.SolutionCatalog;
import com.nbsaas.boot.solution.api.domain.response.SolutionCatalogResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 解决方案分类-实体对象转化成响应对象
*/

public class SolutionCatalogResponseConvert  implements Converter<SolutionCatalogResponse,SolutionCatalog> {

    @Override
    public SolutionCatalogResponse convert(SolutionCatalog source) {
        SolutionCatalogResponse  result = new  SolutionCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                        result.setParent(source.getParent().getId());
                    }
                    if(source.getMobile()!=null){
                        result.setMobile(source.getMobile().getId());
                    }
                    if(source.getAdPosition()!=null){
                        result.setAdPosition(source.getAdPosition().getId());
                    }

                    try {
                        if(source.getParent()!=null){
                            result.setParentName(source.getParent().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getAdPosition()!=null){
                            result.setAdPositionName(source.getAdPosition().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getMobile()!=null){
                            result.setMobileName(source.getMobile().getName());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

